home *** CD-ROM | disk | FTP | other *** search
- /// <summary>
- /// Summary description for VLCUtility
- /// </summary>
- ///
- ///
- ///
- ///
-
- namespace gbweb.classes
- {
- #region VLC Common Core Class - Class Name - VLCCommon
-
- public class VLCCommon
- {
- #region VLC Common Core Class - Class Name - VLCCommon
- private Settings guideParams;
-
- public string strmPlayer;
- public bool strmExternal;
- public string strmVLCLoc;
- public int strmPort;
- public int strmBuffer;
- public string strmPriority;
- public string strmSetting;
- public int strmBitRate;
- public string strmVideoSizeOpt;
- public string strmVideoSize;
- public string strmVideoScale;
- public string strmMux;
- public string strmVideo;
- public string strmAudio;
- public string strmAudoBitrate;
- public string strmAudioChannels;
- public string strmVEncoder;
-
- public VLCCommon(int profileOption)
- {
- guideParams = Global.Settings;
-
- if (profileOption != 2)
- {
- strmPlayer = guideParams.strmPlayer;
- strmExternal = guideParams.strmExternal;
-
- strmVLCLoc = guideParams.strmVLCLoc;
- strmPort = guideParams.strmPort;
- strmBuffer = guideParams.strmBuffer;
- strmPriority = guideParams.strmPriority;
- strmSetting = guideParams.strmSetting;
- strmBitRate = guideParams.strmBitRate;
- strmVideoSizeOpt = guideParams.strmVideoSizeOpt;
- strmVideoSize = guideParams.strmVideoSize;
- strmVideoScale = guideParams.strmVideoScaleSize;
-
- strmMux = guideParams.strmMux;
- strmVideo = guideParams.strmVideo;
- strmAudio = guideParams.strmAudio;
- strmAudoBitrate = guideParams.strmAudoBitrate;
- strmAudioChannels = guideParams.strmAudioChannels;
- strmVEncoder = guideParams.strmVEncoder;
- }
- else
- {
- strmPlayer = guideParams.strmPlayer2;
- strmExternal = guideParams.strmExternal2;
-
- strmVLCLoc = guideParams.strmVLCLoc2;
- strmPort = guideParams.strmPort2;
- strmBuffer = guideParams.strmBuffer2;
- strmPriority = guideParams.strmPriority2;
- strmSetting = guideParams.strmSetting2;
- strmBitRate = guideParams.strmBitRate2;
- strmVideoSizeOpt = guideParams.strmVideoSizeOpt2;
- strmVideoSize = guideParams.strmVideoSize2;
- strmVideoScale = guideParams.strmVideoScaleSize2;
-
- strmMux = guideParams.strmMux2;
- strmVideo = guideParams.strmVideo2;
- strmAudio = guideParams.strmAudio2;
- strmAudoBitrate = guideParams.strmAudoBitrate2;
- strmAudioChannels = guideParams.strmAudioChannels2;
- strmVEncoder = guideParams.strmVEncoder2;
- }
- }
-
- public VLCCommon(string StrmPlayer, bool StrmExternal, string StrmVLCLoc, int StrmPort, int StrmBuffer, string StrmPriority, string StrmSetting,
- int StrmBitRate, string StrmVideoSizeOpt, string StrmVideoSize, string StrmVideoScale, string StrmMux, string StrmVideo,
- string StrmAudio, string StrmAudoBitrate, string StrmAudioChannels, string StrmVEncoder)
- {
- strmPlayer = StrmPlayer;
- strmExternal = StrmExternal;
- strmVLCLoc = StrmVLCLoc;
- strmPort = StrmPort;
- strmBuffer = StrmBuffer;
- strmPriority = StrmPriority;
- strmSetting = StrmSetting;
- strmBitRate = StrmBitRate;
- strmVideoSizeOpt = StrmVideoSizeOpt;
- strmVideoSize = StrmVideoSize;
- strmVideoScale = StrmVideoScale;
- strmMux = StrmMux;
- strmVideo = StrmVideo;
- strmAudio = StrmAudio;
- strmAudoBitrate = StrmAudoBitrate;
- strmAudioChannels = StrmAudioChannels;
- strmVEncoder = StrmVEncoder;
- }
-
-
- public string getPlayer()
- {
- return strmPlayer;
- }
- public void setPlayer(string a)
- {
- strmPlayer = a;
- }
-
- public bool playerIsExternal()
- {
- return strmExternal;
- }
- public void setPlayerIsExternal(bool a)
- {
- strmExternal = a;
- }
-
- public string getVLCLoc()
- {
- return strmVLCLoc;
- }
- public void setVLCLoc(string a)
- {
- strmVLCLoc = a;
- }
-
- public int getStrmPort()
- {
- return strmPort;
- }
- public void setStmPort(int a)
- {
- strmPort = a;
- }
-
- public int getStrmBuffer()
- {
- return strmBuffer;
- }
- public void setStrmBuffer(int a)
- {
- strmBuffer = a;
- }
-
- public string getStrmPriority()
- {
- return strmPriority;
- }
- public void setStrmPriority(string a)
- {
- strmPriority = a;
- }
-
- public string getStrmSetting()
- {
- return strmSetting;
- }
- public void setStrmSetting(string a)
- {
- strmSetting = a;
- }
-
- public int getStrmBitRate()
- {
- return strmBitRate;
- }
- public void setStrmBitRate(int a)
- {
- strmBitRate = a;
- }
- public string getStrmVideoSizeOpt()
- {
- return strmVideoSizeOpt;
- }
- public void setStrmVideoSizeOpt(string a)
- {
- strmVideoSizeOpt = a;
- }
- public string getStrmVideoSize()
- {
- return strmVideoSize;
- }
- public void setStrmVideoSize(string a)
- {
- strmVideoSize = a;
- }
-
- public string getStrmVideoScale()
- {
- return strmVideoScale;
- }
- public void setStrmVideoScale(string a)
- {
- strmVideoScale = a;
- }
-
- public string getStrmMux()
- {
- return strmMux;
- }
- public void setStrmMux(string a)
- {
- strmMux = a;
- }
-
- public string getStrmVideo()
- {
- return strmVideo;
- }
- public void setStrmVideo(string a)
- {
- strmVideo = a;
- }
-
- public string getStrmAudio()
- {
- return strmAudio;
- }
- public void setStrmAudio(string a)
- {
- strmAudio = a;
- }
-
- public string getStrmAudioBitRate()
- {
- return strmAudoBitrate;
- }
- public void setStrmAudioBitRate(string a)
- {
- strmAudoBitrate = a;
- }
-
- public string getStrmAudioChannels()
- {
- return strmAudioChannels;
- }
- public void setStrmAudioChannels(string a)
- {
- strmAudioChannels = a;
- }
-
- public string getStrmVEncoder()
- {
- return strmVEncoder;
- }
- public void setStrmVEncoder(string a)
- {
- strmVEncoder = a;
- }
- #endregion
- #region VLC Command Line Generation Routines
-
- public string genCommandLine(string filename, string StrmSetting, string vsize, string mux, int bit, int port)
- {
- string args;
- string audioCodec;
-
- switch (StrmSetting)
- {
- //MP4 Video, MP4 Aduio, MPEG TS Mux
- case "0":
- {
- args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=mp4v,";
- audioCodec = "mp4a";
- mux = "ts";
- break;
- }
- //WM Video, MP4 Audio, MPEG TS Mux
- case "1":
- {
- args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=WMV2,";
- audioCodec = "mp4a";
- mux = "ts";
- break;
- }
- //WM Video, MP3 Audio, ASF Mux
- case "2":
- {
- args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=WMV2,";
- audioCodec = "mp3";
- mux = "asf";
- break;
- }
- //H264 Video, MP4 Audio, MPEG TS Mux
- case "3":
- {
- args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=h264,";
- audioCodec = "mp4a";
- mux = "ts";
- break;
- }
- //MP4 Video, MP1/2 Audio, MPEG TS Mux
- case "dvs0":
- {
- args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=mp4v,";
- audioCodec = "mpga";
- mux = "ts";
- break;
- }
- //MP2 Video, MP1/2 Audio, MPEG TS Mux
- case "dvs1":
- {
- args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=mp2v,";
- audioCodec = "mpga";
- mux = "ts";
- break;
- }
- //MP1 Video, MP1/2 Audio, MPEG TS Mux
- case "dvs2":
- {
- args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=mp1v,";
- audioCodec = "mpga";
- mux = "ts";
- break;
- }
- //MP4 Video, MP4 Aduio, MPEG TS Mux
- default:
- {
- args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=mp4v,";
- audioCodec = "mp4a";
- mux = "ts";
- break;
- }
- }
-
- if (bit == 0)
- {
- switch (vsize)
- {
- case "320":
- args += "vb=128,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "480":
- args += "vb=128,width=480,height=320,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "720":
- args += "vb=128,width=720,height=480,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- default:
- args += "vb=128,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- }
- }
- else if (bit == 1)
- {
- switch (vsize)
- {
- case "320":
- args += "vb=256,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "480":
- args += "vb=256,width=480,height=320,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "720":
- args += "vb=256,width=720,height=480,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- default:
- args += "vb=256,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- }
- }
- else if (bit == 2)
- {
- switch (vsize)
- {
- case "320":
- args += "vb=512,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "480":
- args += "vb=512,width=480,height=320,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "720":
- args += "vb=512,width=720,height=480,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- default:
- args += "vb=512,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- }
- }
- else if (bit == 3)
- {
- switch (vsize)
- {
- case "320":
- args += "vb=1200,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "480":
- args += "vb=1200,width=480,height=320,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "720":
- args += "vb=1200,width=720,height=480,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- default:
- args += "vb=1200,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- }
- }
- else
- {
- switch (vsize)
- {
- case "320":
- args += "vb=128,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "480":
- args += "vb=128,width=480,height=320,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- case "720":
- args += "vb=128,width=720,height=480,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- default:
- args += "vb=128,width=320,height=213,acodec=" + audioCodec + ",ab=32,channels=2}";
- break;
- }
- }
-
- //Append more info to the argument line being passed to VLC on the server
- args += ":standard{access=http,mux=" + mux + ",url=:" + port + "} vlc:quit";
-
- return (args);
- }
-
- public string genCommandLine(string filename, VLCCommon vlc)
- {
- string args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=" + vlc.getStrmVideo()+ ",";
-
- args = setVideo(args, vlc);
-
- //Append more info to the argument line being passed to VLC on the server
- args += ":standard{access=http,mux=" + vlc.getStrmMux() + ",url=:" + vlc.getStrmPort() + "} vlc:quit";
-
- return args;
-
- }
-
- public string genCommandLine(string filename, VLCCommon vlc, object vencoder)
- {
- string args = "--intf http \"" + filename + "\" :sout=#transcode{vcodec=" + vlc.getStrmVideo();
- string encargs = "";
- if (vencoder is H264Encoder)
- {
- H264Encoder H264 = (H264Encoder) vencoder;
- encargs = "{";
- if (H264.getH264KeyInt() != string.Empty)
- {
- encargs = encargs + "keyint=" + H264.getH264KeyInt()+ ",";
- }
- if (H264.getH264IDRInt() != string.Empty)
- {
- encargs = encargs + "idrint=" + H264.getH264IDRInt() + ",";
- }
- if (H264.getH264BFrames() != string.Empty)
- {
- encargs = encargs + "bframes=" + H264.getH264BFrames() + ",";
- }
- if (H264.getH264QuantizerParam() != string.Empty)
- {
- encargs = encargs + "qp=" + H264.getH264QuantizerParam() + ",";
- }
- if (H264.getH264QuantizerMax() != string.Empty)
- {
- encargs = encargs + "qp-max=" + H264.getH264QuantizerMax() + ",";
- }
- if (H264.getH264QuantizerMin() != string.Empty)
- {
- encargs = encargs + "qp-min=" + H264.getH264QuantizerMin() + ",";
- }
- if (!H264.getH264CABAC())
- {
- encargs = encargs + "cabac=no-cabac,";
- }
- if (!H264.getH264LoopFilter())
- {
- encargs = encargs + "loopfilter=nf,";
- }
- if (!H264.getH264Analyse())
- {
- encargs = encargs + "analyse=none,";
- }
- if (H264.getH264FrameRef() != string.Empty)
- {
- encargs = encargs + "frameref=" + H264.getH264FrameRef() + ",";
- }
- if (H264.getH264Adapt() != string.Empty)
- {
- encargs = encargs + "adapt=" + H264.getH264Adapt() + ",";
- }
- if (H264.getH264Me() != string.Empty)
- {
- encargs = encargs + "me=" + H264.getH264Me() + ",";
- }
- if (H264.getH264SubME() != string.Empty)
- {
- encargs = encargs + "subme=" + H264.getH264SubME() + ",";
- }
- if (H264.getH264ChromaME() != string.Empty)
- {
- encargs = encargs + "chroma-me=" + H264.getH264ChromaME() + ",";
- }
- if (H264.getH264MERange() != string.Empty)
- {
- encargs = encargs + "merange=" + H264.getH264MERange() + ",";
- }
- encargs = encargs + "}";
- }
-
- args = args + encargs + ",";
-
- args = setVideo(args, vlc);
-
- //Append more info to the argument line being passed to VLC on the server
- args += ":standard{access=http,mux=" + vlc.getStrmMux() + ",url=:" + vlc.getStrmPort() + "} vlc:quit";
-
- return args;
- }
-
- private static string setVideo(string args, VLCCommon vlc)
- {
- //Set the variables for bitrate and video size
- int bit = vlc.getStrmBitRate();
- string vsize;
- if (vlc.getStrmVideoSizeOpt() == "preset")
- {
- vsize = vlc.getStrmVideoSize();
- switch (vsize)
- {
- case "320":
- vsize = "width=320,height=213";
- break;
- case "480":
- vsize += "width=480,height=320";
- break;
- case "720":
- vsize += "width=720,height=480";
- break;
- default:
- vsize += "width=320,height=213";
- break;
- }
- }
- else
- {
- vsize = "scale=" + vlc.getStrmVideoScale();
- }
-
- if (bit == 0)
- {
- args += "vb=128," + vsize + ",acodec=" + vlc.getStrmAudio() + ",ab=" + vlc.getStrmAudioBitRate() + ",channels=" + vlc.getStrmAudioChannels() + "}";
- }
- else if (bit == 1)
- {
- args += "vb=256," + vsize + ",acodec=" + vlc.getStrmAudio() + ",ab=" + vlc.getStrmAudioBitRate() + ",channels=" + vlc.getStrmAudioChannels() + "}";
- }
- else if (bit == 2)
- {
- args += "vb=512," + vsize + ",acodec=" + vlc.getStrmAudio() + ",ab=" + vlc.getStrmAudioBitRate() + ",channels=" + vlc.getStrmAudioChannels() + "}";
- }
- else if (bit == 3)
- {
- args += "vb=1200," + vsize + ",acodec=" + vlc.getStrmAudio() + ",ab=" + vlc.getStrmAudioBitRate() + ",channels=" + vlc.getStrmAudioChannels() + "}";
- }
- else
- {
- args += "vb=128," + vsize + ",acodec=" + vlc.getStrmAudio() + ",ab=" + vlc.getStrmAudioBitRate() + ",channels=" + vlc.getStrmAudioChannels() + "}";
- }
- return args;
- }
- #endregion
- }
- #endregion
-
- #region H264 Encoder Settings Class - Class Name = H264Encoder
- public class H264Encoder
- {
- private Settings guideParams;
-
- public string strmH264KeyInt;
- public string strmH264IDRInt;
- public string strmH264BFrames;
- public string strmH264QuantizerParam;
- public string strmH264QuantizerMax;
- public string strmH264QuantizerMin;
- public bool strmH264CABAC;
- public bool strmH264LoopFilter;
- public bool strmH264Analyse;
- public string strmH264FrameRef;
- public string strmH264Adapt;
- public string strmH264Me;
- public string strmH264SubME;
- public string strmH264ChromaME;
- public string strmH264MERange;
-
- public H264Encoder(int profileOption)
- {
- guideParams = Global.Settings;
-
- if (profileOption != 2)
- {
- strmH264KeyInt = guideParams.strmH264KeyInt;
- strmH264IDRInt = guideParams.strmH264IDRInt;
- strmH264BFrames = guideParams.strmH264BFrames;
- strmH264QuantizerMax = guideParams.strmH264QuantizerParam;
- strmH264QuantizerMax = guideParams.strmH264QuantizerMax;
- strmH264QuantizerMin = guideParams.strmH264QuantizerMin;
- strmH264CABAC = guideParams.strmH264CABAC;
- strmH264LoopFilter = guideParams.strmH264LoopFilter;
- strmH264Analyse = guideParams.strmH264Analyse;
- strmH264FrameRef = guideParams.strmH264FrameRef;
- strmH264Adapt = guideParams.strmH264Adapt;
- strmH264Me = guideParams.strmH264Me;
- strmH264SubME = guideParams.strmH264SubME;
- strmH264ChromaME = guideParams.strmH264ChromaME;
- strmH264MERange = guideParams.strmH264MERange;
- }
- else
- {
- strmH264KeyInt = guideParams.strmH264KeyInt2;
- strmH264IDRInt = guideParams.strmH264IDRInt2;
- strmH264BFrames = guideParams.strmH264BFrames2;
- strmH264QuantizerMax = guideParams.strmH264QuantizerParam2;
- strmH264QuantizerMax = guideParams.strmH264QuantizerMax2;
- strmH264QuantizerMin = guideParams.strmH264QuantizerMin2;
- strmH264CABAC = guideParams.strmH264CABAC2;
- strmH264LoopFilter = guideParams.strmH264LoopFilter2;
- strmH264Analyse = guideParams.strmH264Analyse2;
- strmH264FrameRef = guideParams.strmH264FrameRef2;
- strmH264Adapt = guideParams.strmH264Adapt2;
- strmH264Me = guideParams.strmH264Me2;
- strmH264SubME = guideParams.strmH264SubME2;
- strmH264ChromaME = guideParams.strmH264ChromaME2;
- strmH264MERange = guideParams.strmH264MERange2;
- }
- }
-
- public H264Encoder(string StrmH264KeyInt, string StrmH264IDRInt, string StrmH264BFrames, string StrmH264QuantizerParam, string StrmH264QuantizerMax,
- string StrmH264QuantizerMin, bool StrmH264CABAC, bool StrmH264LoopFilter, bool StrmH264Analyse,
- string StrmH264FrameRef, string StrmH264Adapt, string StrmH264Me, string StrmH264SubME,
- string StrmH264ChromaME, string StrmH264MERange)
- {
- strmH264KeyInt = StrmH264KeyInt;
- strmH264IDRInt = StrmH264IDRInt;
- strmH264BFrames = StrmH264BFrames;
- strmH264QuantizerMax = StrmH264QuantizerParam;
- strmH264QuantizerMax = StrmH264QuantizerMax;
- strmH264QuantizerMin = StrmH264QuantizerMin;
- strmH264CABAC = StrmH264CABAC;
- strmH264LoopFilter = StrmH264LoopFilter;
- strmH264Analyse = StrmH264Analyse;
- strmH264FrameRef = StrmH264FrameRef;
- strmH264Adapt = StrmH264Adapt;
- strmH264Me = StrmH264Me;
- strmH264SubME = StrmH264SubME;
- strmH264ChromaME = StrmH264ChromaME;
- strmH264MERange = StrmH264MERange;
- }
-
- public string getH264KeyInt()
- {
- return strmH264KeyInt;
- }
- public void setH264KeyInt(string a)
- {
- strmH264KeyInt = a;
- }
-
- public string getH264IDRInt()
- {
- return strmH264IDRInt;
- }
- public void setH264IDRInt(string a)
- {
- strmH264IDRInt = a;
- }
-
- public string getH264BFrames()
- {
- return strmH264BFrames;
- }
- public void setH264BFrames(string a)
- {
- strmH264BFrames = a;
- }
-
- public string getH264QuantizerParam()
- {
- return strmH264QuantizerParam;
- }
- public void setH264QuantizerParam(string a)
- {
- strmH264QuantizerMax = a;
- }
-
- public string getH264QuantizerMax()
- {
- return strmH264QuantizerMax;
- }
- public void setH264QuantizerMax(string a)
- {
- strmH264QuantizerMax = a;
- }
-
- public string getH264QuantizerMin()
- {
- return strmH264QuantizerMin;
- }
- public void setH264QuantizerMin(string a)
- {
- strmH264QuantizerMin = a;
- }
-
- public bool getH264CABAC()
- {
- return strmH264CABAC;
- }
- public void setH264CABAC(bool a)
- {
- strmH264CABAC = a;
- }
-
- public bool getH264LoopFilter()
- {
- return strmH264LoopFilter;
- }
- public void setH264LoopFilter(bool a)
- {
- strmH264LoopFilter = a;
- }
-
- public bool getH264Analyse()
- {
- return strmH264Analyse;
- }
- public void setH264Analyse(bool a)
- {
- strmH264Analyse = a;
- }
-
- public string getH264FrameRef()
- {
- return strmH264FrameRef;
- }
- public void setH264FrameRef(string a)
- {
- strmH264FrameRef = a;
- }
-
- public string getH264Adapt()
- {
- return strmH264Adapt;
- }
- public void setH264Adapt(string a)
- {
- strmH264Adapt = a;
- }
-
- public string getH264Me()
- {
- return strmH264Me;
- }
- public void setH264Me(string a)
- {
- strmH264Me = a;
- }
-
- public string getH264SubME()
- {
- return strmH264SubME;
- }
- public void setH264SubME(string a)
- {
- strmH264SubME = a;
- }
-
- public string getH264ChromaME()
- {
- return strmH264ChromaME;
- }
- public void setH264ChromaME(string a)
- {
- strmH264ChromaME = a;
- }
-
- public string getH264MERange()
- {
- return strmH264MERange;
- }
- public void setH264MERange(string a)
- {
- strmH264MERange = a;
- }
- }
- #endregion
- }
-